package cn.itrigger.dynamic.sql.util;

import java.util.StringJoiner;
import java.util.stream.Collector;

/**
 * @author admin
 * @date 2018/9/26
 **/
public interface CustomCollectors {
    static Collector<CharSequence, StringJoiner, String> joining(CharSequence delimiter, CharSequence prefix, CharSequence suffix) {
        return Collector.of(() -> {
           StringJoiner sj = new StringJoiner(delimiter, prefix, suffix);
           sj.setEmptyValue("");
           return sj;
        }, StringJoiner::add, StringJoiner::merge, StringJoiner::toString);
    }
}
